package com.fansl.allround.ucenter.api.feign;

import com.fansl.allround.common.core.bean.UserInfo;
import com.fansl.allround.common.core.constant.SecurityConstants;
import com.fansl.allround.common.core.constant.ServiceNameConstants;
import com.fansl.allround.common.core.constant.enums.OauthTypeEnum;
import com.fansl.allround.ucenter.api.dto.BindSocialInfoDTO;
import com.fansl.allround.ucenter.api.entity.UcenterUser;
import com.fansl.allround.ucenter.api.feign.factory.RemoteUcenterUserServiceFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * @author fansl
 * @Description: TODO
 * @date 2019/9/25 11:07
 */
@FeignClient(contextId = "remoteUcenterUserService",value = ServiceNameConstants.UCENTER_SERVICE,fallbackFactory = RemoteUcenterUserServiceFallbackFactory.class)
public interface RemoteUcenterUserService {
    /**
     * 获取用户中心信息
     * @param oauthName 认证信息
     * @param oauthType 认证类型
     * @param from 内部访问的标志
     * @return
     */
    @GetMapping("/user/info")
    UserInfo info(@RequestParam("oauthName") String oauthName,
                  @RequestParam("oauthType") OauthTypeEnum oauthType,
                  @RequestHeader(SecurityConstants.FROM) String from);

    /**
     * 创建用户信息（带认证信息）
     * @param ucenterUser 用户信息
     * @param oauthValue 认证信息
     * @param oauthType 认证类型
     * @param from 内部访问的标志
     * @return
     */
    @PostMapping("/user/create")
    UserInfo create(@RequestBody UcenterUser ucenterUser,
                           @RequestParam("oauthValue")String oauthValue,
                           @RequestParam("oauthType")OauthTypeEnum oauthType,
                           @RequestHeader(SecurityConstants.FROM) String from);

    /**
     * 根据用户Id获取用户信息
     * @param userId 用户Id
     * @param from 内部访问的标志
     * @return
     */
    @GetMapping("/user/{userId}")
    UserInfo getByUserId(@PathVariable("userId")String userId,
                    @RequestHeader(SecurityConstants.FROM) String from);

    /**
     * 绑定用户社交信息
     * @param bindSocialInfo
     * @param from
     * @return
     */
    @PostMapping("/inner/user/bind")
    Boolean bindSocialUser(@RequestBody BindSocialInfoDTO bindSocialInfo,
                           @RequestHeader(SecurityConstants.FROM) String from);
}
